package com.ruoyi.project.tool.swagger.UserController;

import java.util.List;

import com.ruoyi.framework.aspectj.lang.annotation.SignatureValidation;
import com.ruoyi.framework.interceptor.annotation.RepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysMoments;
import com.ruoyi.project.system.service.ISysMomentsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 精彩瞬间评论图片Controller
 *
 * @author jjp
 * @date 2020-04-21
 */
@RestController
@Api(description = "精彩瞬间评论图片Controller")
@RequestMapping("/mobileUser/moments")
public class UserMomentsController extends BaseController {
    @Autowired
    private ISysMomentsService sysMomentsService;

    /**
     * 查询精彩瞬间评论图片列表
     */
//    @GetMapping("/list")
    public TableDataInfo list(SysMoments sysMoments) {
        startPage();
        List<SysMoments> list = sysMomentsService.selectSysMomentsList(sysMoments);
        return getDataTable(list);
    }


    /**
     * 获取精彩瞬间评论图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:moments:query')")
    @ApiOperation("获取精彩瞬间评论图片详细信息")
    @GetMapping(value = "/{commentId}")
    public AjaxResult getInfo(@PathVariable("commentId") Long commentId) {
        return AjaxResult.success(sysMomentsService.selectSysMomentsById(commentId));
    }

    /**
     * 新增精彩瞬间评论图片
     */
    @SignatureValidation
    @RepeatSubmit
    @ApiOperation("新增精彩瞬间评论图片")
    @Log(title = "精彩瞬间评论图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMoments sysMoments) {
        sysMomentsService.insertSysMoments(sysMoments);
        Long commentId = sysMoments.getCommentId();
        return AjaxResult.success(commentId);
    }

    /**
     * 修改精彩瞬间评论图片
     */
    @ApiOperation("修改精彩瞬间评论图片")
    @SignatureValidation
    @RepeatSubmit
    @Log(title = "精彩瞬间评论图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMoments sysMoments) {
        return toAjax(sysMomentsService.updateSysMoments(sysMoments));
    }

    /**
     * 删除精彩瞬间评论图片
     */
    @ApiOperation("删除精彩瞬间评论图片")
    @SignatureValidation
    @Log(title = "精彩瞬间评论图片", businessType = BusinessType.DELETE)
    @DeleteMapping("/{commentIds}")
    public AjaxResult remove(@PathVariable Long[] commentIds) {
        return toAjax(sysMomentsService.deleteSysMomentsByIds(commentIds));
    }
}
